/*
 * AllTermQueryElement.java
 *
 * Created on September 8, 2007, 9:10 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.adl.registry.website.lucene;

import java.util.Iterator;

/**
 *
 * @author Jacob
 */
public class AllTermQueryElement extends InputStringQueryElement implements QueryElement
{
    /** Creates a new instance of AnyTermQueryElement */
    public AllTermQueryElement()
    {
        super();
    }
    
    /** Creates a new instance of AnyTermQueryElement */
    public AllTermQueryElement(String value)
    {
        super(value);
    }
    
    public String toString()
    {
        StringBuilder builder = new StringBuilder();
        
        int counter = 0;
        
        Iterator<String> iterator = super.getElementParts().iterator();
        
        while(iterator.hasNext())
        {
            String value = iterator.next();
            
            if (counter == 0)
            {
                builder.append(value);
            }
            else
            {
                String formatted = " AND " + value;
                
                builder.append(formatted);
            }
            
            counter++;
        }
        
        return builder.toString();
    }
    
}
